﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using BOHVote.BLL;

namespace BOH.DataManagement
{
    public partial class JobRankModify : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["ID"] != null)
                {
                    LoadJobRankByID(Request.QueryString["ID"].ToString());
                }
            }
        }

        public void LoadJobRankByID(string jobRankID)
        {
            DataSet dst = OtherClass.getJobRankByID(jobRankID);
            txtJobRankName.Text = dst.Tables[0].Rows[0]["JobRankName"].ToString();
            drplevel.SelectedValue = dst.Tables[0].Rows[0]["JobRankLevel"].ToString();
            drpStatus.SelectedValue = dst.Tables[0].Rows[0]["Status"].ToString();
        }

        protected void butSave_Click(object sender, EventArgs e)
        {
            string JobRankName = txtJobRankName.Text;
            string JobRankLevel = drplevel.SelectedValue;
            string Status = drpStatus.SelectedValue;
            if (Request.QueryString["ID"] != null)
            {
                OtherClass.UpdateJobRank(Request.QueryString["ID"].ToString(), JobRankName, JobRankLevel, Status);
            }
            else
            {
                OtherClass.AddJobRank(JobRankName, JobRankLevel, Status);
            }
        }
    }
}
